# 在goland环境下对链程序进行编译
FROM golang:1.21.5 as builder
LABEL authors="yunyuanshengzhinan"
# 将当前目录添加到容器
ADD . /goweb
RUN go env -w GOPROXY=https://goproxy.cn,direct && cd /goweb  &&  go build -o main ./main.go && ls

# 完成编译后，将编译成功的二进制文件copy到新的容器当中，减小容器的大小
FROM alpine:latest
RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2
COPY --from=builder /goweb/main /bin/main
EXPOSE     8081
ENTRYPOINT [ "/bin/main" ]
